<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="util" uri="/WEB-INF/kdd-util.tld" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<sec:authorize access="isAuthenticated()">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        </head>
        <body>
            <jsp:include page="menu.jsp" />
            <script type="text/javascript">
                $(function() { 
                    var t = $('table#listtable')
                    $("#filter").keyup(function() {
                        $.uiTableFilter( t, this.value );
                    })
                });  
            </script>
            <h2><spring:message code="msg.welcome" />, <sec:authentication property="principal.username"></sec:authentication></h2>
            <c:if test="${not empty followProjects}">
                <div class="well notfull">
                    <h2><spring:message code="msg.followedsubprojects" /></h2><br />
                    <div class="well">
                        <table class="table table-striped table-bordered table-condensed ">
                            <thead>
                                <tr>
                                    <th class="creationdate"><spring:message code="msg.name" /></th>
                                    <th class="creationdate"><spring:message code="msg.project" /></th>
                                    <th class="creationdate"><spring:message code="msg.created" /></th>
                                    <th class="details"><spring:message code="msg.details" /></th>
                                </tr>
                            </thead>
                            <tbody>
                                <c:forEach items="${followProjects}" var="sp">
                                    <tr>
                                        <td>${sp.name}</td>
                                        <td><a href="<c:url value='/project/${sp.parent.id}' />">${sp.parent.name}</a></td>
                                        <td><fmt:formatDate value="${sp.creationDate}" pattern="MM/dd/yyyy HH:mm"/></td>
                                        <td><a class="btn btn-mini btn-info" href="<c:url value='/subproject/${sp.id}' />"><spring:message code="msg.details" /></a></td>
                                    </tr>
                                </c:forEach>
                            </tbody>
                        </table>
                    </div>
                </div>
            </c:if>
            <c:if test="${not empty events}">
                <div class="well row-fluid notfull">
                    <h4><spring:message code="msg.events" /></h4><br />
                    <div>
                        <input type="text" id="filter" placeholder="Filter" />
                        <table id="listtable" class="table table-bordered table-condensed notfull">
                            <thead>
                                <tr>
                                    <th><spring:message code="msg.events" /></th>
                                </tr>
                            </thead>
                            <tbody>
                                <c:forEach items="${events}" var="e">
                                    <tr>
                                        <td class="${util:getTypeColor(e.type)} borderbottom">
                                            <strong><spring:message code="msg.subproject" />:</strong> <a href="<c:url value='/subproject/${e.subProject.id}'/>">${e.subProject.name}</a>
                                            - <strong><spring:message code="msg.created" />:</strong> <fmt:formatDate value="${e.creationDate}" pattern="MM/dd/yyyy HH:mm"/><br />
                                            ${e.text}
                                        </td>
                                    </tr>
                                </c:forEach>
                            </tbody>
                        </table>
                        <strong><a href="<c:url value='/events'/>"><spring:message code="msg.showallevents" /></a></strong>
                    </div>
                </div>
            </c:if>
            <div class="well row-fluid notfull">
                <h4><spring:message code="msg.statistics" /></h4><br />
                <div class="row-fluid">
                    <div class="span6 alert-info">
                        <ul>
                            <li><strong>${users}</strong> <spring:message code="msg.users" /></li>
                            <li><strong>${projects}</strong> <spring:message code="msg.projects" /></li>
                            <li><strong>${subprojects}</strong> <spring:message code="msg.subprojects" /></li>
                            <li><strong>${methods}</strong> <spring:message code="msg.methods" /></li>
                        </ul>
                    </div>
                    <div class="span6 alert-info"> 
                        <ul>
                            <li><strong>${comments}</strong> <spring:message code="msg.comments" /></li>
                            <li><strong>${data}</strong> <spring:message code="msg.data" /></li>
                            <li><strong>${results}</strong> <spring:message code="msg.results" /></li>
                            <li><strong>${eventstat}</strong> <spring:message code="msg.events" /></li>
                        </ul>
                    </div>
                </div>
            </div>
            <jsp:include page="foot.jsp" />
        </sec:authorize>